
#region copyright notice
/* ====================================================================
 * The UncleGED Open Source Software License
 *
 * Copyright (c) 1999-2009 D. M. DeBacker. All rights reserved.
 * http://gatheringleaves.org/uged
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. Products derived from this software may not be called "UncleGED",
 *    nor may "UncleGED" appear in their name, without prior written
 *    permission of D. M. DeBacker.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL D. M. DEBACKER BE LIABLE FOR ANY 
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 */
#endregion


using System;
using System.Collections;
using System.Collections.Specialized;
using UncleGED.Utils;

namespace UncleGED.Collections
{
   //===========================
	/// <summary>
	/// Object that represents a child of a Family
	/// </summary>
	/// <tocexclude />
   public class Child
   {

      private string mvarFamilyID;
      private string mvarChildID;

		/// <summary>
		/// Constructor for the Child object
		/// </summary>
		public Child()
		{
		}


		/// <summary>
		/// The ID (RIN) of the child
		/// </summary>
      public string ChildID
      {
         get
         {
            return mvarChildID;
         }
         set
         {
            mvarChildID = value;
         }
      }


		/// <summary>
		/// The ID (MRIN) of the family to which the child belongs
		/// </summary>
      public string FamilyID
      {
         get
         {
            return mvarFamilyID;
         }
         set
         {
            mvarFamilyID = value;
         }
      }

   }


   //===========================
	/// <summary>
	/// Object that represents a family.
	/// </summary>
	/// <remarks>A family consists of union between two individuals</remarks>
	/// <tocexclude />
	public class Family
   {

      private string mvarID = "";
      private string mvarHusband = "";
      private string mvarWife = "";
      private string mvarMarriageDateText = "";
      private string mvarMarriagePlace = "";
      private string mvarDivorcePlace = "";
      private string mvarDivorceDateText = "";
      private LifeEvents mvarLifeEvents = new LifeEvents();
      private Sources mvarSources = new Sources();
      private bool mvarHasChildren = false;
      private string mvarNotes = "";
      private string mvarReferenceNumber = "";
      private DateTime mvarLastChangeDate;
      private bool mvarDidMarry;

		/// <summary>
		/// Constructor for Family object
		/// </summary>
      public Family()
      {
         mvarID = "";
         mvarHusband = "";
         mvarWife = "";
         mvarMarriageDateText = "";
         mvarMarriagePlace = "";
         mvarDivorcePlace = "";
         mvarDivorceDateText = "";
         mvarLifeEvents = new LifeEvents();
         mvarSources = new Sources();
         mvarHasChildren = false;
         mvarNotes = "";
         mvarReferenceNumber = "";
         mvarLastChangeDate = new DateTime();
         mvarDidMarry = false;
      }


		/// <summary>
		/// Record change (CHAN) date
		/// </summary>
      public DateTime LastChangeDate
      {
         get
         {
            return mvarLastChangeDate;
         }
         set
         {
            mvarLastChangeDate = value;
         }
      }


		/// <summary>
		/// Custom reference number assigned to this union
		/// </summary>
      public string ReferenceNumber
      {
         get
         {
            return mvarReferenceNumber;
         }
         set
         {
            mvarReferenceNumber = value;
         }
      }


		/// <summary>
		/// Notes for the marriage or union
		/// </summary>
      public string Notes
      {
         get
         {
            return mvarNotes;
         }
         set
         {
            mvarNotes = value;
         }
      }



		/// <summary>
		/// Flag indicating whether this family has children
		/// </summary>
      public bool HasChildren
      {
         get
         {
            return mvarHasChildren;
         }
         set
         {
            mvarHasChildren = value;
         }
      }

		/// <summary>
		/// Collection of Sources for this marriage or union
		/// </summary>
		public Sources Sources
      {
         get
         {

            return mvarSources;
         }
         set
         {
            mvarSources = value;
         }
      }

		/// <summary>
		/// A collection of events for this family
		/// </summary>
      public LifeEvents LifeEvents
      {
         get
         {

            return mvarLifeEvents;
         }
         set
         {
            mvarLifeEvents = value;
         }
      }

		/// <summary>
		/// Date text when the marriage or union ended
		/// </summary>
      public string DivorceDateText
      {
         get
         {
            return mvarDivorceDateText;
         }
         set
         {
            mvarDivorceDateText = value;
         }
      }


		/// <summary>
		/// Location where the union or marriage ended
		/// </summary>
      public string DivorcePlace
      {
         get
         {
            return mvarDivorcePlace;
         }
         set
         {
            mvarDivorcePlace = value;
         }
      }


		/// <summary>
		/// Location where union or marriage began
		/// </summary>
      public string MarriagePlace
      {
         get
         {
            return mvarMarriagePlace;
         }
         set
         {
            mvarMarriagePlace = value;
         }
      }


		/// <summary>
		/// Date text of when marriage or union began
		/// </summary>
      public string MarriageDateText
      {
         get
         {
            return mvarMarriageDateText;
         }
         set
         {
            mvarMarriageDateText = value;
         }
      }


		/// <summary>
		/// ID (RIN) for the Wife (female) in this marriage or union
		/// </summary>
      public string Wife
      {
         get
         {
            return mvarWife;
         }
         set
         {
            mvarWife = value;
         }
      }


		/// <summary>
		/// ID (RIN) of the Husband (male) in this union
		/// </summary>
      public string Husband
      {
         get
         {
            return mvarHusband;
         }
         set
         {
            mvarHusband = value;
         }
      }


		/// <summary>
		/// ID (MRIN) of this family
		/// </summary>
      public string ID
      {
         get
         {
            return mvarID;
         }
         set
         {
            mvarID = value;
         }
      }

		/// <summary>
		/// Flag indicating whether the individuals have a marriage event that united the couple
		/// </summary>
      public bool DidMarry
      {
         get
         {
            return mvarDidMarry;
         }
         set
         {
            mvarDidMarry = value;
         }
      }

   }


	/// <summary>
	/// Object that contains information regarding the GEDCOM file
	/// </summary>
	/// <tocexclude/>
	public class GedcomFileInfo
   {

      private string mvarSource;
      private string mvarSourceName;
      private string mvarVersion;
      private string mvarCreationDate;
      private string mvarCreationTime;
      private string mvarSourceFile;
      private string mvarSubmitterName;
      private string mvarSubmitterEmail;


		/// <summary>
		/// Email of person who submitted the GEDCOM
		/// </summary>
      public string SubmitterEmail
      {
         get
         {
            return (mvarSubmitterEmail);
         }
         set
         {
            mvarSubmitterEmail = value;
         }
      }


		/// <summary>
		/// Name of person who submitted the GEDCOM
		/// </summary>
      public string SubmitterName
      {
         get
         {
            return (mvarSubmitterName);
         }
         set
         {
            mvarSubmitterName = value;
         }
      }


		/// <summary>
		/// Name of the source file
		/// </summary>
      public string SourceFile
      {
         get
         {
            return (mvarSourceFile);
         }
         set
         {
            mvarSourceFile = value;
         }
      }


		/// <summary>
		/// Creation time of the GEDCOM file
		/// </summary>
      public string CreationTime
      {
         get
         {
            return (mvarCreationTime);
         }
         set
         {
            mvarCreationTime = value;
         }
      }


		/// <summary>
		/// Date the GEDCOM was created
		/// </summary>
      public string CreationDate
      {
         get
         {
            return (mvarCreationDate);
         }
         set
         {
            mvarCreationDate = value;
         }
      }


		/// <summary>
		/// Gedcom version
		/// </summary>
      public string Version
      {
         get
         {
            return mvarVersion;
         }
         set
         {
            mvarVersion = value;
         }
      }


		/// <summary>
		/// Name of the source
		/// </summary>
      public string SourceName
      {
         get
         {
            return mvarSourceName;
         }
         set
         {
            mvarSourceName = value;
         }
      }


		/// <summary>
		/// Source of the GEDCOM file
		/// </summary>
      public string Source
      {
         get
         {
            return mvarSource;
         }
         set
         {
            mvarSource = value;
         }
      }
   }


   //============================
	/// <summary>
	/// Object that represents an inviduals
	/// </summary>
	/// <tocexclude />
	public class Individual
   {

      private string mvarSurname = "";
      private string mvarForenames = "";
      private string mvarSex = "";
      private string mvarBirthDateText = "";
      private string mvarBirthPlace = "";
      private string mvarBaptismDateText = "";
      private string mvarBaptismPlace = "";
      private string mvarDeathDateText = "";
      private string mvarBurialDateText = "";
      private string mvarDeathPlace = "";
      private string mvarAddress = "";
      private string mvarReferenceNumber = "";
      private string mvarNotes = "";
      private string mvarID = "";
      private string mvarBurialPlace = "";
      private string mvarAliasName = "";
      private string mvarNationality = "";
      private string mvarSuffix = "";
      private LifeEvents mvarLifeEvents = new LifeEvents();
      private Sources mvarSources = new Sources();
      private string mvarFamilyID = "";
      private bool mvarHasOwnFamily = false;
      private string mvarLinkPage = "";
      private DateTime mvarLastChangeDate;
      private FamList mvarFamList = new FamList();
      private int mvarMinBirthYear;
      private int mvarMaxBirthYear;
      private bool mvarDidEstimate;
      private string mvarPafUniqueID = "";
      private int mvarLineNumber;
		private bool mvarGotName;
		private string mvarTitle = "";

		/// <summary>
		/// Title given to an individual
		/// </summary>
		public string Title
		{
			get { return mvarTitle; }
			set { mvarTitle = value; }
		}
		
		/// <summary>
		/// Flag to handle multiple NAME entries
		/// </summary>
		public bool GotName
		{
			get { return mvarGotName; }
			set { mvarGotName = value; }
		}

		/// <summary>
		/// Constructor for the Indvidual object
		/// </summary>
      public Individual()
      {

         mvarSurname = "";
         mvarForenames = "";
         mvarSex = "";
         mvarBirthDateText = "";
         mvarBirthPlace = "";
         mvarBaptismDateText = "";
         mvarBaptismPlace = "";
         mvarDeathDateText = "";
         mvarBurialDateText = "";
         mvarDeathPlace = "";
         mvarAddress = "";
         mvarReferenceNumber = "";
         mvarNotes = "";
         mvarID = "";
         mvarBurialPlace = "";
         mvarAliasName = "";
         mvarNationality = "";
         mvarSuffix = "";
         mvarHasOwnFamily = false;
         mvarMinBirthYear = 1300;
         mvarMaxBirthYear = DateTime.Now.Year;
         mvarFamilyID = "";
         mvarLastChangeDate = new DateTime();
			mvarGotName = false;

      }

		/// <summary>
		/// Line number in GEDCOM where the  indvidual appears
		/// </summary>
      public int LineNumber
      {
         get
         {
            return mvarLineNumber;
         }
         set
         {
            mvarLineNumber = value;
         }
      }

		/// <summary>
		/// PAF Unique ID for the indvidual
		/// </summary>
      public string PafUniqueID
      {
         get
         {
            return mvarPafUniqueID;
         }
         set
         {
            mvarPafUniqueID = value;
         }
      }

		/// <summary>
		/// Was the individual's birth date estimated?
		/// </summary>
      public bool DidEstimate
      {
         get
         {
            return mvarDidEstimate;
         }
         set
         {
            mvarDidEstimate = value;
         }
      }

		/// <summary>
		/// Set by date estimation tool
		/// </summary>
      public int MinBirthYear
      {
         get
         {
            return mvarMinBirthYear;
         }
         set
         {
            mvarMinBirthYear = value;
         }
      }

		/// <summary>
		/// Set by date estimation tool
		/// </summary>
      public int MaxBirthYear
      {
         get
         {
            return mvarMaxBirthYear;
         }
         set
         {
            mvarMaxBirthYear = value;
         }
      }

		/// <summary>
		/// List of family links to which this individual is a head of household member
		/// </summary>
      public FamList FamList
      {
         get
         {
            return mvarFamList;
         }
         set
         {
            mvarFamList = value;
         }
      }

		/// <summary>
		/// Last change date for the  indvidual's record
		/// </summary>
      public DateTime LastChangeDate
      {
         get
         {
            return mvarLastChangeDate;
         }
         set
         {
            mvarLastChangeDate = value;
         }
      }


		/// <summary>
		/// The page where this  indvidual appears
		/// </summary>
      public string LinkPage
      {
         get
         {
            return mvarLinkPage;
         }
         set
         {
            mvarLinkPage = value;
         }
      }


		/// <summary>
		/// True if individual is a head of household in a family or union
		/// </summary>
      public bool HasOwnFamily
      {
         get
         {
            return mvarHasOwnFamily;
         }
         set
         {
            mvarHasOwnFamily = value;
         }
      }


		/// <summary>
		/// Family ID (MRIN) that the individual belongs to
		/// </summary>
      public string FamilyID
      {
         get
         {
            return mvarFamilyID;
         }
         set
         {
            mvarFamilyID = value;
         }
      }


		/// <summary>
		/// Collection of sources for the indvidual
		/// </summary>
      public Sources Sources
      {
         get
         {
            return mvarSources;
         }
         set
         {
            mvarSources = value;
         }
      }


		/// <summary>
		/// Collection of life events for the  indvidual
		/// </summary>
      public LifeEvents LifeEvents
      {
         get
         {
            return mvarLifeEvents;
         }
         set
         {
            mvarLifeEvents = value;
         }
      }


		/// <summary>
		/// Name suffix for the indvidual
		/// </summary>
      public string Suffix
      {
         get
         {
            return mvarSuffix;
         }
         set
         {
            mvarSuffix = value;
         }
      }


		/// <summary>
		/// Nationality of the indvidual
		/// </summary>
      public string Nationality
      {
         get
         {
            return mvarNationality;
         }
         set
         {
            mvarNationality = value;
         }
      }


		/// <summary>
		/// Alias name
		/// </summary>
      public string AliasName
      {
         get
         {
            return mvarAliasName;
         }
         set
         {
            mvarAliasName = value;
         }
      }


		/// <summary>
		/// Burial place
		/// </summary>
      public string BurialPlace
      {
         get
         {
            return mvarBurialPlace;
         }
         set
         {
            mvarBurialPlace = value;
         }
      }


		/// <summary>
		/// ID (RIN) of the indvidual
		/// </summary>
      public string ID
      {
         get
         {
            return mvarID;
         }
         set
         {
            mvarID = value;
         }
      }


		/// <summary>
		/// Notes for the indvidual
		/// </summary>
      public string Notes
      {
         get
         {
            return mvarNotes;
         }
         set
         {
            mvarNotes = value;
         }
      }


		/// <summary>
		/// Custom reference number for the indvidual
		/// </summary>
      public string ReferenceNumber
      {
         get
         {
            return mvarReferenceNumber;
         }
         set
         {
            mvarReferenceNumber = value;
         }
      }


		/// <summary>
		/// Address of the individual
		/// </summary>
      public string Address
      {
         get
         {
            return mvarAddress;
         }
         set
         {
            mvarAddress = value;
         }
      }


		/// <summary>
		/// Death place
		/// </summary>
      public string DeathPlace
      {
         get
         {
            return mvarDeathPlace;
         }
         set
         {
            mvarDeathPlace = value;
         }
      }


		/// <summary>
		/// Burial date
		/// </summary>
      public string BurialDateText
      {
         get
         {
            return mvarBurialDateText;
         }
         set
         {
            mvarBurialDateText = value;
         }
      }


		/// <summary>
		/// Death death
		/// </summary>
      public string DeathDateText
      {
         get
         {
            return mvarDeathDateText;
         }
         set
         {
            mvarDeathDateText = value;
         }
      }


		/// <summary>
		/// Baptism place
		/// </summary>
      public string BaptismPlace
      {
         get
         {
            return mvarBaptismPlace;
         }
         set
         {
            mvarBaptismPlace = value;
         }
      }


		/// <summary>
		/// Baptism date
		/// </summary>
      public string BaptismDateText
      {
         get
         {
            return mvarBaptismDateText;
         }
         set
         {
            mvarBaptismDateText = value;
         }
      }


		/// <summary>
		/// Birth place
		/// </summary>
      public string BirthPlace
      {
         get
         {
            return mvarBirthPlace;
         }
         set
         {
            mvarBirthPlace = value;
         }
      }


		/// <summary>
		/// Birth date
		/// </summary>
      public string BirthDateText
      {
         get
         {
            return mvarBirthDateText;
         }
         set
         {
            mvarBirthDateText = value;
         }
      }


		/// <summary>
		/// Sex of the indvidual
		/// </summary>
      public string Sex
      {
         get
         {
            return mvarSex;
         }
         set
         {
            mvarSex = value;
         }
      }


		/// <summary>
		/// Forenames of the individual
		/// </summary>
      public string Forenames
      {
         get
         {
            return mvarForenames;
         }
         set
         {
            mvarForenames = value;
         }
      }


		/// <summary>
		/// Surname of the indvidual
		/// </summary>
      public string Surname
      {
         get
         {
            return mvarSurname;
         }
         set
         {
            mvarSurname = value;
         }
      }

		/// <summary>
		/// True if the individual's data is private
		/// </summary>
		/// <remarks>added in 9.07</remarks>
		private bool mvarIsPrivate;

		/// <summary>
		/// True if the  indvidual was marked private
		/// </summary>
		public bool IsPrivate
		{
			get { return mvarIsPrivate; }
			set { mvarIsPrivate = value; }
		}

		/// <summary>
		/// Numeric portion of the RIN
		/// </summary>
		public int IdNumber
		{
			get
			{
				StringFunctions sf = new StringFunctions();
				int idnumber;
				string id;
				try
				{
					id = sf.Right(mvarID, sf.Len(mvarID) - 2);
					id = sf.Left(id, sf.Len(id) - 1);
					idnumber = System.Int32.Parse(id);
				}
				catch 
				{
					idnumber = 0;
				} 
				return idnumber;
			}
		}
   }


	/// <summary>
	/// 
	/// </summary>
	/// <tocexclude />
	public class LifeEvent
   {
		/// <summary>
		/// Enumeration of event types
		/// </summary>
		/// <tocexclude/>
      public enum EventTypes
      {
			/// <summary>
			/// Event type
			/// </summary>
         etUnknown = 0,
			/// <summary>
			/// Event type
			/// </summary>
         etBirth,
			/// <summary>
			/// Event type
			/// </summary>
         etBaptism,
			/// <summary>
			/// Event type
			/// </summary>
         etDeath,
			/// <summary>
			/// Event type
			/// </summary>
         etBurial,
			/// <summary>
			/// Event type
			/// </summary>
         etOccupation,
			/// <summary>
			/// Event type
			/// </summary>
         etMarriage,
			/// <summary>
			/// Event type
			/// </summary>
         etResidence,
			/// <summary>
			/// Event type
			/// </summary>
         etImmigration,
			/// <summary>
			/// Event type
			/// </summary>
         etMilitary,
			/// <summary>
			/// Event type
			/// </summary>
         etDeathOfSpouse,
			/// <summary>
			/// Event type
			/// </summary>
         etDivorce,
			/// <summary>
			/// Event type
			/// </summary>
         etOther,
			/// <summary>
			/// Event type
			/// </summary>
         etNationality,
			/// <summary>
			/// Event type
			/// </summary>
         etElected,
			/// <summary>
			/// Event type
			/// </summary>
         etExcommunicated,
			/// <summary>
			/// Event type
			/// </summary>
         etMission,
			/// <summary>
			/// Event type
			/// </summary>
         etBaptismLDS,
			/// <summary>
			/// Event type
			/// </summary>
         etBar_Mitzvah,
			/// <summary>
			/// Event type
			/// </summary>
         etBat_Mitzvah,
			/// <summary>
			/// Event type
			/// </summary>
         etBlessing,
			/// <summary>
			/// Event type
			/// </summary>
         etCaste,
			/// <summary>
			/// Event type
			/// </summary>
         etCensus,
			/// <summary>
			/// Event type
			/// </summary>
         etChristening,
			/// <summary>
			/// Event type
			/// </summary>
         etConfirmation,
			/// <summary>
			/// Event type
			/// </summary>
         etConfirmationLDS,
			/// <summary>
			/// Event type
			/// </summary>
         etCremation,
			/// <summary>
			/// Event type
			/// </summary>
         etEducation,
			/// <summary>
			/// Event type
			/// </summary>
         etEmigration,
			/// <summary>
			/// Event type
			/// </summary>
         etEndowmentLDS,
			/// <summary>
			/// Event type
			/// </summary>
         etFirstCommunion,
			/// <summary>
			/// Event type
			/// </summary>
         etGraduation,
			/// <summary>
			/// Event type
			/// </summary>
         etNaturalization,
			/// <summary>
			/// Event type
			/// </summary>
         etOrdination,
			/// <summary>
			/// Event type
			/// </summary>
         etProbate,
			/// <summary>
			/// Event type
			/// </summary>
         etProperty,
			/// <summary>
			/// Event type
			/// </summary>
         etReligion,
			/// <summary>
			/// Event type
			/// </summary>
         etRetirement,
			/// <summary>
			/// Event type
			/// </summary>
         etSealedToParentsLDS,
			/// <summary>
			/// Event type
			/// </summary>
         etSSN,
			/// <summary>
			/// Event type
			/// </summary>
         etWill,
			/// <summary>
			/// Event type
			/// </summary>
         etChange,
      };

      private EventTypes mvarEventType;
      private string mvarEventDateString = "";
		private string mvarEventPlace = "";
		private string mvarID = "";
		private string mvarEventText = "";
		private string mvarEventNote = "";
		private string mvarEventDescription = "";

		private string CleanHtml(string data)
		{
			data = data.Replace("&", "&amp;");
			return data;
		}


		/// <summary>
		/// The description of the event
		/// </summary>
      public string EventDescription
      {
         get
         {
            return mvarEventDescription;
         }
         set
         {
            mvarEventDescription = CleanHtml(value);
         }
      }

		/// <summary>
		/// Notes associated with the event
		/// </summary>
      public string EventNote
      {
         get
         {
            return mvarEventNote;
         }
         set
         {
            mvarEventNote = CleanHtml(value);
         }
      }


		/// <summary>
		/// Event Label
		/// </summary>
      public string EventText
      {
         get
         {
            return mvarEventText;
         }
         set
         {
            mvarEventText = CleanHtml(value);
         }
      }


		/// <summary>
		/// ID of the event
		/// </summary>
      public string ID
      {
         get
         {
            return mvarID;
         }
         set
         {
            mvarID = value;
         }
      }


		/// <summary>
		/// Place (location) where the event occurred
		/// </summary>
      public string EventPlace
      {
         get
         {
            return mvarEventPlace;
         }
         set
         {
            mvarEventPlace = CleanHtml(value);
         }
      }


		/// <summary>
		/// Date of the event
		/// </summary>
      public string EventDateString
      {
         get
         {
            return mvarEventDateString;
         }
         set
         {
            mvarEventDateString = value;
         }
      }


		/// <summary>
		/// The type of the Event
		/// </summary>
      public EventTypes EventType
      {
         get
         {
            return mvarEventType;
         }
         set
         {
            mvarEventType = value;
         }
      }
   }


	/// <summary>
	/// 
	/// </summary>
	/// <tocexclude />
	public class Location
   {

      private string mvarLocationName = "";
      private string mvarPersonName = "";
      private LifeEvent.EventTypes mvarEventType = LifeEvent.EventTypes.etUnknown;


		/// <summary>
		/// Type of event that occurred at the location
		/// </summary>
      public LifeEvent.EventTypes EventType
      {
         get
         {
            return mvarEventType;
         }
         set
         {
            mvarEventType = value;
         }
      }


		/// <summary>
		/// The name of the person associated with the event
		/// </summary>
      public string PersonName
      {
         get
         {
            return mvarPersonName;
         }
         set
         {
            mvarPersonName = value;
         }
      }


		/// <summary>
		/// The name of the location
		/// </summary>
      public string LocationName
      {
         get
         {
            return mvarLocationName;
         }
         set
         {
            mvarLocationName = value;
         }
      }
   }


	/// <summary>
	/// Object representing a Note found in the GEDCOM
	/// </summary>
	/// <tocexclude/>
	public class Note
   {

      private string mvarID = "";
      private string mvarNoteText = "";

		/// <summary>
		/// Constructor for note object
		/// </summary>
      public Note()
      {
         mvarID = "";
         mvarNoteText = "";
      }

		/// <summary>
		/// Text of the note
		/// </summary>
      public string NoteText
      {
         get
         {
            return mvarNoteText;
         }
         set
         {
            mvarNoteText = value;
         }
      }

		/// <summary>
		/// ID of the note
		/// </summary>
      public string ID
      {
         get
         {
            return mvarID;
         }
         set
         {
            mvarID = value;
         }
      }
   }


	/// <summary>
	/// Object that represents an invidual's occupation
	/// </summary>
	/// <tocexclude/>
	public class Occupation
   {

      private string mvarOccupationTitle;
      private string mvarPersonName;
      private int mvarOrigIndex;


		/// <summary>
		/// The person's name
		/// </summary>
      public string PersonName
      {
         get
         {
            return mvarPersonName;
         }
         set
         {
            mvarPersonName = value;
         }
      }

		/// <summary>
		/// Occupation title
		/// </summary>
      public string OccupationTitle
      {
         get
         {
            return mvarOccupationTitle;
         }
         set
         {
            mvarOccupationTitle = value;
         }
      }

		/// <summary>
		/// The original index of the occupation
		/// </summary>
      public int OrigIndex
      {
         get
         {
            return mvarOrigIndex;
         }
         set
         {
            mvarOrigIndex = value;
         }
      }

   }


	/// <summary>
	/// Object that represents Sources found in the GEDCOM
	/// </summary>
	/// <tocexclude/>
	public class Source
   {

      private string mvarID = "";
      private string mvarTitle = "";
      private string mvarSourceText = "";
      private string mvarPublicationInfo = "";
      private string mvarAuthor = "";
      private string mvarMedia = "";
      private string mvarNote = "";
      private string mvarPage = "";
      private string mvarEventTag = "";
      private string mvarAbbreviation = "";

		/// <summary>
		/// Constructor for the Source class
		/// </summary>
      public Source()
      {
          mvarID = "";
          mvarTitle = "";
          mvarSourceText = "";
          mvarPublicationInfo = "";
          mvarAuthor = "";
          mvarMedia = "";
          mvarNote = "";
          mvarPage = "";
          mvarEventTag = "";
          mvarAbbreviation = "";
      }

		/// <summary>
		/// Source abbreviation
		/// </summary>
      public string Abbreviation
      {
         get
         {
            return mvarAbbreviation;
         }
         set
         {
            mvarAbbreviation = value;
         }
      }


		/// <summary>
		/// Source event tag
		/// </summary>
      public string EventTag
      {
         get
         {
            return mvarEventTag;
         }
         set
         {
            mvarEventTag = value;
         }
      }


		/// <summary>
		/// Source page
		/// </summary>
      public string Page
      {
         get
         {
            return mvarPage;
         }
         set
         {
            mvarPage = value;
         }
      }


		/// <summary>
		/// Source notes
		/// </summary>
      public string Note
      {
         get
         {
            return mvarNote;
         }
         set
         {
            mvarNote = value;
         }
      }


		/// <summary>
		/// Source media
		/// </summary>
      public string Media
      {
         get
         {
            return mvarMedia;
         }
         set
         {
            mvarMedia = value;
         }
      }


		/// <summary>
		/// Source author
		/// </summary>
      public string Author
      {
         get
         {
            return mvarAuthor;
         }
         set
         {
            mvarAuthor = value;
         }
      }


		/// <summary>
		/// Source publication info
		/// </summary>
      public string PublicationInfo
      {
         get
         {
            return mvarPublicationInfo;
         }
         set
         {
            mvarPublicationInfo = value;
         }
      }


		/// <summary>
		/// Source text
		/// </summary>
      public string SourceText
      {
         get
         {
            return mvarSourceText;
         }
         set
         {
            mvarSourceText = value;
         }
      }


		/// <summary>
		/// Source title
		/// </summary>
      public string Title
      {
         get
         {
            return mvarTitle;
         }
         set
         {
            mvarTitle = value;
         }
      }


		/// <summary>
		/// Source ID
		/// </summary>
      public string ID
      {
         get
         {
            return mvarID;
         }
         set
         {
            mvarID = value;
         }
      }
   }


	/// <summary>
	/// 
	/// </summary>
	/// <tocexclude />
	public class Surname
   {

      private string mvarFamilyName;
      private string mvarFirstLink;
      private int mvarNumItems;

		/// <summary>
		/// Constructor for the class
		/// </summary>
      public Surname()
      {
         mvarFamilyName = "";
         mvarFirstLink = "";
         mvarNumItems = 1;
      }


		/// <summary>
		/// Number of occurances of this surname
		/// </summary>
      public int NumItems
      {
         get
         {
            return mvarNumItems;
         }
         set
         {
            mvarNumItems = value;
         }
      }


		/// <summary>
		/// The first person that the surname links to
		/// </summary>
      public string FirstLink
      {
         get
         {
            return mvarFirstLink;
         }
         set
         {
            mvarFirstLink = value;
         }
      }


		/// <summary>
		/// Family name (ie surname)
		/// </summary>
      public string FamilyName
      {
         get
         {
            return mvarFamilyName;
         }
         set
         {
            mvarFamilyName = value;
         }
      }

   }



   #region Collection Classes

	/// <summary>
	/// A collection of child objects
	/// </summary>
	/// <tocexclude />
	public class Children : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add new child to the collection
		/// </summary>
		/// <param name="NewChild">Child object to add</param>
		/// <returns>true if successful</returns>
      public bool Add(Child NewChild)
      {

         string key;

         try
         {
            //the key is formed by conc the fam id and the child id
            key = NewChild.FamilyID + NewChild.ChildID;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewChild);
            return true;
         }
         catch
         {
            return false;
         }
      }


		/// <summary>
		/// Clear all objects from the collection
		/// </summary>
      public void Clear()
      {
         this.BaseClear();
      }

      // the Remove method that takes a string key
		/// <summary>
		/// Removes the entries with the specified key from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="key">key of object to remove</param>
      public void Remove(string key)
      {
			this.BaseRemove(key);
      }

      // the Remove method that takes a numeric index
		/// <summary>
		/// Removes the entries at the specified index from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="index">index of object to remove</param>
      public void Remove(int index)
      {
			this.BaseRemoveAt(index);
      }

      /// <summary>
		/// the Item property that takes a string key
      /// </summary>
      /// <param name="key"></param>
      /// <returns></returns>
      public Child this[string key]
      {
         get { return (Child)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

      /// <summary>
		/// the Item property that takes a numeric index
      /// </summary>
      /// <param name="index"></param>
      /// <returns></returns>
      public Child this[int index]
      {
         get { return (Child)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Returns an enumerator that iterates through the NameObjectCollectionBase.
		/// </summary>
      public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Children parent;
         Child currObject;
         int index = 0;

         public myEnumerator(Children fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

   }


	/// <summary>
	/// 
	/// </summary>
	/// <tocexclude />
	public class Families : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

      /// <summary>
      /// Adds a new family object to the collection
      /// </summary>
      /// <param name="NewFamily">Family object to add</param>
      /// <returns>true if successful</returns>
		public bool Add(Family NewFamily)
      {
         string key;

         try
         {
            key = NewFamily.ID;
            //attempt to add key to hashtable. this will fail if key is already in table
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewFamily);
            return true;
         }
         catch
         {
            return false;
         }

      }

		/// <summary>
		/// Clear all objects from the collection
		/// </summary>
		public void Clear()
      {
         this.BaseClear();
      }

      // the Remove method that takes a string key
		/// <summary>
		/// Removes the entries with the specified key from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="key">key of object to remove</param>
		public void Remove(string key)
      {
         this.BaseRemove(key);
      }

		/// <summary>
		/// Removes the entries at the specified index from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="index">index of object to remove</param>
		public void Remove(int index)
      {
         this.BaseRemoveAt(index);
      }

      /// <summary>
		/// the Item property that takes a string key
      /// </summary>
      /// <param name="key"></param>
      /// <returns></returns>
      public Family this[string key]
      {
         get { return (Family)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

      /// <summary>
		/// the Item property that takes a numeric index
      /// </summary>
      /// <param name="index"></param>
      /// <returns></returns>
      public Family this[int index]
      {
         get { return (Family)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }


		/// <summary>
		/// Returns an enumerator that iterates through the NameObjectCollectionBase.
		/// </summary>
		public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Families parent;
         Family currObject;
         int index = 0;

         public myEnumerator(Families fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

   }


	/// <summary>
	/// A collection of Individuals
	/// </summary>
	/// <tocexclude />
	public class Individuals : System.Collections.Specialized.NameObjectCollectionBase
   {
      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add new individual to the collection
		/// </summary>
		/// <param name="NewIndividual">Indvidual object to add</param>
		/// <returns>true if successful</returns>
		public bool Add(Individual NewIndividual)
      {
         string key;
         try
         {
            key = NewIndividual.ID;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewIndividual);
            return true;
         }
         catch
         {
            return false;
         }
      }

		/// <summary>
		/// Clear all objects from the collection
		/// </summary>
		public void Clear()
      {
         this.BaseClear();
      }

      // the Remove method that takes a string key
		/// <summary>
		/// Removes the entries with the specified key from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="key">key of object to remove</param>
		public void Remove(string key)
      {
         this.BaseRemove(key);
      }

      // the Remove method that takes a numeric index
		/// <summary>
		/// Removes the entries at the specified index from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="index">index of object to remove</param>
		public void Remove(int index)
      {
			this.BaseRemoveAt(index);
      }

		/// <summary>
		/// the Item property that takes a string key
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public Individual this[string key]
      {
         get { return (Individual)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

      /// <summary>
		/// the Item property that takes a numeric index
      /// </summary>
      /// <param name="index"></param>
      /// <returns></returns>
      public Individual this[int index]
      {
         get { return (Individual)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Returns an enumerator that iterates through the NameObjectCollectionBase.
		/// </summary>
		public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Individuals parent;
         Individual currObject;
         int index = 0;

         public myEnumerator(Individuals fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }

      }

   }


	/// <summary>
	/// A collection of Life Events
	/// </summary>
	/// <tocexclude />
	public class LifeEvents : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add new child to the collection
		/// </summary>
		/// <param name="NewEvent">Event object to add</param>
		/// <returns>true if successful</returns>
		public bool Add(LifeEvent NewEvent)
      {

         try
         {
            string key;
            key = NewEvent.ID;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewEvent);
            return true;
         }
         catch
         {
            return false;
         }
      }


		/// <summary>
		/// Clear all objects from the collection
		/// </summary>
		public void Clear()
      {
         this.BaseClear();
      }

		// the Remove method that takes a string key
		/// <summary>
		/// Removes the entries with the specified key from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="key">key of object to remove</param>
		public void Remove(string key)
      {
         this.BaseRemove(key);
      }

		// the Remove method that takes a numeric index
		/// <summary>
		/// Removes the entries at the specified index from the NameObjectCollectionBase instance.
		/// </summary>
		/// <param name="index">index of object to remove</param>
		public void Remove(int index)
      {
         this.BaseRemoveAt(index);
      }

      /// <summary>
		/// the Item property that takes a string key
      /// </summary>
      /// <param name="key"></param>
      /// <returns></returns>
      public LifeEvent this[string key]
      {
         get { return (LifeEvent)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public LifeEvent this[int index]
      {
         get { return (LifeEvent)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Returns an enumerator that iterates through the NameObjectCollectionBase.
		/// </summary>
		public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         LifeEvents parent;
         LifeEvent currObject;
         int index = 0;

         public myEnumerator(LifeEvents fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

		/// <summary>
		/// Count of non-excluded events
		/// </summary>
		public int IncludedCount
		{
			get
			{
				int cnt = 0;
				for (int index = 0; index < this.Count; index++)
				{
					LifeEvent le = (LifeEvent)this.BaseGet(index);
					if (le.EventText != "!") cnt++;
				}
				return cnt;
			}
		}

   }


	/// <summary>
	/// Collection of locations
	/// </summary>
	/// <tocexclude/>
	public class Locations : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add a new location
		/// </summary>
      public bool Add(string LocationName, string PersonName, LifeEvent.EventTypes EventType, string key)
      {

         //create a new object
         Location objNewMember = new Location();

         try
         {
            //set the properties passed into the method
            objNewMember.LocationName = LocationName;
            objNewMember.PersonName = PersonName;
            objNewMember.EventType = EventType;

            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, objNewMember);

            return true;
         }
         catch
         {
            return false;
         }
      }


		/// <summary>
		/// Dump the internal hash table
		/// </summary>
      public void DumpHt()
      {
         ht.Clear();
      }

		/// <summary>
		/// Clear location objects
		/// </summary>
      public void Clear()
      {
         this.BaseClear();
      }

      // the Remove method that takes a string key
		/// <summary>
		/// Remove the location with the specified key
		/// </summary>
      public void Remove(string key)
      {
         this.BaseRemove(key);
      }

      // the Remove method that takes a numeric index
		/// <summary>
		/// Remove the location at the specified index
		/// </summary>
      public void Remove(int index)
      {
         this.BaseRemoveAt(index);
      }

		/// <summary>
		/// the Item property that takes a string key
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public Location this[string key]
      {
         get { return (Location)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Location this[int index]
      {
         get { return (Location)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Used the itterate the locations collection
		/// </summary>
      public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Locations parent;
         Location currObject;
         int index = 0;

         public myEnumerator(Locations fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

   }


	/// <summary>
	/// Collection of Notes
	/// </summary>
	/// <tocexclude/>
	public class Notes : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add a new note object to the collection
		/// </summary>
      public bool Add(Note NewNote)
      {
         string key;

         try
         {
            key = NewNote.ID;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewNote);
            return true;
         }
         catch
         {
            return false;
         }
      }

		/// <summary>
		/// Clear all objects from the collection
		/// </summary>
      public void Clear()
      {
         this.BaseClear();
      }

      // the Remove method that takes a string key
		/// <summary>
		/// Remove object with specified key
		/// </summary>
      public void Remove(string key)
      {
         this.BaseRemove(key);
      }

      // the Remove method that takes a numeric index
		/// <summary>
		/// Remove object with specified index
		/// </summary>
      public void Remove(int index)
      {
			this.BaseRemoveAt(index);
      }

		/// <summary>
		/// the Item property that takes a string key
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public Note this[string key]
      {
         get { return (Note)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Note this[int index]
      {
         get { return (Note)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Used to itterate the collection
		/// </summary>
      public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Notes parent;
         Note currObject;
         int index = 0;

         public myEnumerator(Notes fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

   }


	/// <summary>
	/// Collection of occupation objects
	/// </summary>
	/// <tocexclude/>
	public class Occupations : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add a new occupation to the collection
		/// </summary>
      public Occupation Add(string OccupationTitle, string PersonName, string key)
      {
         //create a new object
         Occupation o = new Occupation();

         try
         {
            //set the properties passed into the method
            o.OccupationTitle = OccupationTitle;
            o.PersonName = PersonName;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, o);

            //return the object created
            return o;
         }
         catch
         {
            return null;
         }
      }

		/// <summary>
		/// Clear all occupation from the collection
		/// </summary>
      public void Clear()
      {
         this.BaseClear();
      }

      // the Remove method that takes a string key
		/// <summary>
		/// Remove object with specifiied key
		/// </summary>
      public void Remove(string key)
      {
         this.BaseRemove(key);
      }

      // the Remove method that takes a numeric index
		/// <summary>
		/// Remove object at specified index
		/// </summary>
      public void Remove(int index)
      {
         this.BaseRemoveAt(index);
      }

		/// <summary>
		/// the Item property that takes a string key
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public Occupation this[string key]
      {
         get { return (Occupation)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Occupation this[int index]
      {
         get { return (Occupation)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Used to itterate the collection
		/// </summary>
      public new IEnumerator GetEnumerator()
      {
         // return an instance of the inner enumerator object
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Occupations parent;
         Occupation currObject;
         int index = 0;

         public myEnumerator(Occupations fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

   }


	/// <summary>
	/// 
	/// </summary>
	/// <tocexclude />
	public class Sources : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add a new source item
		/// </summary>
		/// <param name="NewSource"></param>
		/// <returns></returns>
      public bool Add(Source NewSource)
      {
         string key;
         try
         {
            key = NewSource.ID;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewSource);
            return true;
         }
         catch
         {
            return false;
         }
      }

		/// <summary>
		/// clear the item
		/// </summary>
      public void Clear()
      {
         this.BaseClear();
      }

      /// <summary>
		/// the Remove method that takes a string key
      /// </summary>
      /// <param name="key"></param>
      public void Remove(string key)
      {
         this.BaseRemove(key);
      }

		/// <summary>
		/// the Remove method that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		public void Remove(int index)
      {
         this.BaseRemoveAt(index);
      }

      /// <summary>
		/// the Item property that takes a string key
      /// </summary>
      /// <param name="key"></param>
      /// <returns></returns>
      public Source this[string key]
      {
         get { return (Source)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Source this[int index]
      {
         get { return (Source)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }

		/// <summary>
		/// Return an instance of the inner enumerator object
		/// </summary>
		/// <returns></returns>
      public new IEnumerator GetEnumerator()
      {
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Sources parent;
         Source currObject;
         int index = 0;

         public myEnumerator(Sources fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }

   }


	/// <summary>
	/// Collection of surnames
	/// </summary>
	/// <tocexclude />
	public class Surnames : System.Collections.Specialized.NameObjectCollectionBase
   {

      Hashtable ht = new Hashtable();

		/// <summary>
		/// Add a surname
		/// </summary>
		/// <param name="NewSurname"></param>
		/// <returns></returns>
      public bool Add(Surname NewSurname)
      {
         string key;
         try
         {
            key = NewSurname.FamilyName;
            ht.Add(key, null); //will fail if duplicate key 	
            this.BaseAdd(key, NewSurname);
            return true;
         }
         catch
         {
            return false;
         }
      }

		/// <summary>
		/// Clear all items from the collection
		/// </summary>
		public void Clear()
      {
         this.BaseClear();
      }

		/// <summary>
		/// the Remove method that takes a string key
		/// </summary>
		/// <param name="key"></param>
		public void Remove(string key)
      {
         this.BaseRemove(key);
      }

		/// <summary>
		/// the Remove method that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		public void Remove(int index)
      {
         this.BaseRemoveAt(index);
      }

		/// <summary>
		/// the Item property that takes a string key
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public Surname this[string key]
      {
         get { return (Surname)this.BaseGet(key); }
         set { this.BaseSet(key, value); }
      }

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Surname this[int index]
      {
         get { return (Surname)this.BaseGet(index); }
         set { this.BaseSet(index, value); }
      }
		/// <summary>
		/// return an instance of the inner enumerator object
		/// </summary>
		/// <returns></returns>
		public new IEnumerator GetEnumerator()
      {
         return new myEnumerator(this);
      }

      private class myEnumerator : IEnumerator
      {
         // a reference to the parent object
         Surnames parent;
         Surname currObject;
         int index = 0;

         public myEnumerator(Surnames fc)
         {
            this.parent = fc;
         }

         // the IEnumerator interface (three methods)

         public bool MoveNext()
         {
            if (index < parent.Count)
            {
               currObject = parent[index];
               index++;
               return true;
            }
            else
            {
               index = 0;
               return false;
            }
         }

         public object Current
         {
            get
            {
               // just return the line read by MoveNext
               return currObject;
            }
         }

         public void Reset()
         {
            // this method is never called and can be left empty
         }
      }
   }


   #endregion

	/// <summary>
	/// Used in building ahnentafels
	/// </summary>
	public class Ancestor
	{
		/// <summary>
		/// Individual ID (RIN) of this ancestor
		/// </summary>
		private string _personId;

		/// <summary>
		/// The generation that this ancestor belongs to
		/// </summary>
		public string PersonId
		{
			get { return _personId; }
			set { _personId = value; }
		}
		/// <summary>
		/// Ahnentafel number of this ancestor
		/// </summary>
		/// <tocexclude />
		private int _ancestorNumber;

		/// <summary>
		/// Individual ID (RIN) of this ancestor
		/// </summary>
		public int AncestorNumber
		{
			get { return _ancestorNumber; }
			set { _ancestorNumber = value; }
		}
		/// <summary>
		/// The generation that this ancestor belongs to
		/// </summary>
		private int _generationNumber;

		/// <summary>
		/// Ahnentafel number of this ancestor
		/// </summary>
		public int GenerationNumber
		{
			get { return _generationNumber; }
			set { _generationNumber = value; }
		}
	}

	/// <summary>
	/// Collection of Ancestors
	/// </summary>
	/// <tocexclude />
	public class Ancestors : System.Collections.Specialized.NameObjectCollectionBase
	{

		Hashtable ht = new Hashtable();

		/// <summary>
		/// Add an Ancestor
		/// </summary>
		/// <param name="NewAncestor"></param>
		/// <returns></returns>
		public bool Add(Ancestor NewAncestor)
		{
			string key;
			try
			{
				key = NewAncestor.PersonId;
				ht.Add(key, null); //will fail if duplicate key 	
				this.BaseAdd(key, NewAncestor);
				return true;
			}
			catch
			{
				return false;
			}
		}

		/// <summary>
		/// Clear all items from the collection
		/// </summary>
		public void Clear()
		{
			this.BaseClear();
		}

		/// <summary>
		/// the Remove method that takes a string key
		/// </summary>
		/// <param name="key"></param>
		public void Remove(string key)
		{
			this.BaseRemove(key);
		}

		/// <summary>
		/// the Remove method that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		public void Remove(int index)
		{
			this.BaseRemoveAt(index);
		}

		/// <summary>
		/// the Item property that takes a string key
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public Ancestor this[string key]
		{
			get { return (Ancestor)this.BaseGet(key); }
			set { this.BaseSet(key, value); }
		}

		/// <summary>
		/// the Item property that takes a numeric index
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Ancestor this[int index]
		{
			get { return (Ancestor)this.BaseGet(index); }
			set { this.BaseSet(index, value); }
		}
		/// <summary>
		/// return an instance of the inner enumerator object
		/// </summary>
		/// <returns></returns>
		public new IEnumerator GetEnumerator()
		{
			return new myEnumerator(this);
		}

		private class myEnumerator : IEnumerator
		{
			// a reference to the parent object
			Ancestors parent;
			Ancestor currObject;
			int index = 0;

			public myEnumerator(Ancestors fc)
			{
				this.parent = fc;
			}

			// the IEnumerator interface (three methods)

			public bool MoveNext()
			{
				if (index < parent.Count)
				{
					currObject = parent[index];
					index++;
					return true;
				}
				else
				{
					index = 0;
					return false;
				}
			}

			public object Current
			{
				get
				{
					// just return the line read by MoveNext
					return currObject;
				}
			}

			public void Reset()
			{
				// this method is never called and can be left empty
			}
		}
	}
}
